package com.kl.nest;

import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlElementWrapper;
import lombok.Data;

import java.util.List;

/**
 * 需求是序列号Person对象，嵌套了Address对象至xml，最终xml如下
 * <Person>
 *     <firstName>super</firstName>
 *     <lastName>lkl</lastName>
 *     <phoneNumbers>
 *         <phoneNumbers>18386868888</phoneNumbers>
 *         <phoneNumbers>18386849999</phoneNumbers>
 *     </phoneNumbers>
 *     <address>
 *         <streetName>洪湖东路</streetName>
 *         <city>渝北区</city>
 *     </address>
 *     <address>
 *         <streetName>八一路</streetName>
 *         <city>渝中区</city>
 *     </address>
 * </Person>
 */
@Data
public final class Person {
    @JsonProperty("FirstName")
    private String firstName;
    @JsonProperty("LastName")
    private String lastName;
    @JacksonXmlElementWrapper(localName = "PhoneNumbers")
    private List<String> phoneNumbers;
    // 电话号码被phoneNumbers元素包装，而地址没有
    // 我们可以通过@JacksonXMLElementWrapper 注解表达这种差异
    @JacksonXmlElementWrapper(useWrapping = false,localName = "Address")
    private List<Address> address;

    @JacksonXmlElementWrapper(localName = "Students")
    private List<Student> students;

    // 类里面有集合
    @JsonProperty("Teacher")
    private Teacher teacher;
}
